<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp"%>
<!DOCTYPE html>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="usersForm">
							<input type="hidden" name="id" value="${id}">
							<div class="form-group">
								<label class="col-sm-3 control-label">新密码：</label>
								<div class="col-sm-8">
									<input type="password" id='newPassword' class="form-control" name="newPassword">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-3 control-label">确认密码：</label>
								<div class="col-sm-8">
									<input type="password" class="form-control" name="verifyPassword">
								</div>
							</div>



							<div class="form-group">
								<div class="col-sm-4 col-sm-offset-2">
									<button class="btn btn-primary" type="submit">保存</button>
								</div>
							</div>
						</form>

						<div align="center">
							<shiro:hasPermission name="user_uppwd">
								<button class="btn btn-outline btn-danger" type="" id="closeIframe">关闭</button>
							</shiro:hasPermission>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>

	<script src="${ctx}/static/js/plugins/CryptoJS/core.js"></script>
	<script src="${ctx}/static/js/plugins/CryptoJS/cipher-core.js"></script>
	<script src="${ctx}/static/js/plugins/CryptoJS/tripledes.js"></script>
	<script src="${ctx}/static/js/plugins/CryptoJS/mode-ecb.js"></script>
	<script src="${ctx}/static/js/plugins/CryptoJS/enc-base64.js"></script>
	<script type="text/javascript">
		$('#closeIframe').click(function() {
			closeParentWindow();
		});
		$().ready(function() {

			var e = "<i class='fa fa-times-circle'></i> ";
			$("#usersForm").validate({
				rules : {
					newPassword : {
						required : true,
						minlength : 6,
						maxlength : 20
					},
					verifyPassword : {
						required : true,
						equalTo : "#newPassword"
					},
				},
				messages : {
					newPassword : "${fns:getErrorMessage('ERROR_PSWD')}",
					verifyPassword : "${fns:getErrorMessage('ERROR_CHECK_PSWD')}",
				},
				submitHandler : function(form) {
					var data = formToJson("usersForm");
					data.newPassword = encryptByDES(data.newPassword, "${fnc:getCookieValue('XSRF-TOKEN')}".split('-').join(''));
					data.verifyPassword = encryptByDES(data.verifyPassword, "${fnc:getCookieValue('XSRF-TOKEN')}".split('-').join(''));

					$.post(basePath + "/user/savePwd", data, function(data) {
						if (data.success) {
							succuceMsg(data.msg);
							parent.$("#queryTable").bootstrapTable('refresh');
							delayCloseParentWindow();
						} else {
							errorMsg(data.msg);
						}
					}, "json");
				}
			});
		});
	</script>
</body>
</html>